<?php
/**
 * 业务处理
 */

namespace app\index\business;

class BusinessFactory{

    /**
     * 对象容器
     * @var array
     */
    private static $_business = array();

    /**
     * 获取对象
     * @param $businessName
     * @return object
     * @throws \Exception
     */
    public static function getBusiness($businessName){
        $businessName = __NAMESPACE__ . "\\" . ucfirst($businessName);
        if(!class_exists($businessName)){
            throw new \Exception("{$businessName}类不存在");
        }
        if(!isset(self::$_business[$businessName]) || empty(self::$_business[$businessName])){
            self::$_business[$businessName] = new $businessName();
        }
        return self::$_business[$businessName];
    }

}